package cn.cl.controller;

import cn.cl.service.ContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 标题：
 * 作者：何处是归程
 * 时间：2020/4/12 - 20:28
 */
@RestController
public class ContentController {
	@Autowired
	private ContentService contentService;

	/**
	 * 将数据存入ES中
	 */
	@GetMapping("/parse/{keywords}")
	public Boolean parsre(@PathVariable("keywords") String keywords) {
		return contentService.parseContent(keywords);
	}

	/**
	 * 从ES中读取数据
	 */
	@GetMapping("/search/{keyword}/{pageNo}/{pageSize}")
	public List<Map<String, Object>> search(
			@PathVariable("keyword") String keyword,
			@PathVariable("pageNo") Integer pageNo,
			@PathVariable("pageSize") Integer pageSize) {
		return contentService.searchPage(keyword, pageNo, pageSize);
	}
}
